package com.lovo.model;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

@Entity  //实体类的标识
@Table(name = "s_class")  // 映射的表名
@Data
@NoArgsConstructor
public class ClassBean {
    @Id  //数据ID的标识
    @Column(name = "pk_cid")  //字段名的映射
    @GenericGenerator(name = "hbincrement", strategy = "increment")
// 获取最大值
    @GeneratedValue(generator = "hbincrement")
    private Integer classId;
    @Column(name = "c_name")
    private String name;
    @OneToMany(mappedBy = "classBean")
    private List<StudentBean> studentBeanList = new ArrayList<>();

    public ClassBean(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "ClassBean{" +
                "classId=" + classId +
                ", name='" + name + '\'' +
                '}';
    }
}
